<?php
    defined('INDEX') or die ('Acesso direto n&atilde;o permitido');
    
    /**
     * This class implements all parser functions for application. The
     * access of this class and methods can be across ApplicationFactory::getParserFactory()
     * 
     * @author Carlos A. Junior
     */
	class Parser
	{
		/**
		 * This function parse an string to int value.
		 * 
		 * @param string $value
		 * 
		 * @return int $value
		 */
		public function parseInteger ($value)
		{
			$value = preg_replace('/[a-zA-Z]/', '', $value);
			
        	return (int) $value;
		}
		
		/**
		 * This function parse an string to double value.
		 * 
		 * @param string $value
		 * 
		 * @return double $value
		 */
		public function parseDouble ($value)
		{
			$value = preg_replace('/[a-zA-Z]/', '', $value);
			
			if(preg_match('/,/', $value))
        	{
        		$value = str_replace(array('.', ','), array('', '.'), $value);
        	}
        	
        	return (double) $value;
		}
	}
?>